﻿//
// Copyright (c) 2024 BPer
//
#ifndef BPERENCODER_SRC_BPERH265ENCODERMETA_H_
#define BPERENCODER_SRC_BPERH265ENCODERMETA_H_
#include <bperavutil/video/BPerVideoEncoderMeta.h>
#include <bperutil/BPerAvInfoType.h>
#include <bperutil/sys/BPerLoadLib.h>
#include <x265.h>

class BPerH265EncoderMeta:public BPerVideoEncoderMeta {
public:
	BPerH265EncoderMeta();
	virtual ~BPerH265EncoderMeta();
	void bPer_initVmd(BPerVideoMeta *p_vmd, BPerVideoInfo *p_config, BPerVideoEncInfo *penc);
private:
	void bPer_getH265Config(uint8_t *p_configBuf, int32_t *p_configLen,
			BPerVideoInfo *p_config);
	void bPer_getSpsPps(BPerH2645Conf *p265, BPerVideoInfo *config, BPerVideoEncInfo *penc);

	BPerLoadLib m_lib;
	void loadLib();
	void unloadLib();
	x265_param *(*bPer_x265_param_alloc)(void);
	void (*bPer_x265_param_free)(x265_param *);
	void (*bPer_x265_param_default)(x265_param*);
	int32_t (*bPer_x265_param_default_preset)(x265_param *, const char *preset, const char *tune);
	int32_t (*bPer_x265_param_apply_profile)(x265_param*, const char *profile);
	int32_t (*bPer_x265_encoder_headers)(x265_encoder*, x265_nal **pp_nal, int32_t *pi_nal);

	void (*bPer_x265_encoder_close)(x265_encoder*);
	x265_encoder* (*bPer_x265_encoder_open)(x265_param*);
};

#endif /* BPERENCODER_SRC_BPERH265ENCODERMETA_H_ */
